<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../../vue.js"></script>
</head>

<body>
    <div class="box">
        <p v-if='age < 12'>小学</p>
        <p v-else-if="age >= 12 && age < 18">中学</p>
        <p v-else>大学</p>
        <p v-show='float'>上学</p>
        <p v-show='!float'>不上学</p>
        <button @click='handle'>切换</button>
    </div>
    <script>
        var vm = new Vue({
            el: '.box',
            data: {
                float: false,
                age: 20
            },
            methods: {
                handle() {
                    this.float = !this.float
                }
            }
        })
    </script>
</body>

</html>